home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1998 July
/
EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso
/
cd-sup
/
ider
/
routines
/
launchaction.s
< prev
next >
Wrap
Text File
|
1998-05-24
|
6KB
|
144 lines
LaunchAction: Clr.W _ErrorCode ;there _shouldn't_ be any errors with this routine
Tst.B _Successful ;did one of the check routines succeed?
Bne.S .Successful ;if so, then run the commandline
Tst.L _Suffix ;the following six lines are simply to make
Bne CheckLoop ;sure that only the DEFUALT class is run
Tst.L _Name ;if none of the check routines actually
Bne CheckLoop ;managed to match anything out of the file
Tst.L _Offset
Bne CheckLoop
Bra.S Launch
.Successful Cmp.B #MODE_TWO,_Mode ;does the command require at least two correct entries
Bne.S Launch ;if not, then ignore the check
Cmp.B #2,_Successful ;is the number of correct entries greater or equal to 2
Blt CheckLoop ;if not, then check for a new class
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Launch: Tst.L _WBMessage ;were we launhced from workbench?
Beq.S .NoWB ;if not, ignore the following
CloneWbPath _WBMessage(PC) ;get workbench paths
Move.L D0,_WBPaths ;save this for use in NP_Path
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
.NoWB Lea _SystemTags,A4 ;list of custom options for the launching of programs
Move.L _Stack(PC),D1 ;was STACK available
Tst.L D1 ;was the tag actually mentioned in the class config
Beq.S .NoStack
Move.L #WorkData,D2 ;and a place to strore a number
CALL StrToLong,DOS ;convert the string into a longword
Cmp.L #-1,D0 ;fail if something went wrong
Beq.S .NoStack ;but don't set the tag to anything
Move.L #NP_StackSize,(A4)+ ;the tag ID for the stack
Move.L WorkData,(A4)+ ;the amount of stack to allocate
.NoStack
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Move.L _Pri(PC),D1 ;was PRI found in the class entry
Tst.L D1
Beq.S .NoPri ;if not, skip the tag entry
Move.L #WorkData,D2 ;and a place to strore a number
CALL StrToLong,DOS ;convert the string into a longword
Cmp.L #-1,D0 ;fail if something went wrong
Beq.S .NoPri ;but don't set the tag to anything
Move.L WorkData,D0 ;value returned by StrToLong()
Cmp.L #127,D0 ;maximum of 127
Bgt.S .NoPri ;no entry if they mucked up
Cmp.L #-127,D0 ;minimum of -127
Blt.S .NoPri ;again, skip it if they put in a wrong number
Move.L #NP_Priority,(A4)+ ;the tag ID for PRI
Move.L D0,(A4)+ ;the number we got from the class entry
.NoPri
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Move.L _WBPaths(PC),D0 ;is there an entry from CloneWbPath()
Tst.L D0
Beq.S .NoPaths ;if not, then skip the tag entry
Move.L #NP_Path,(A4)+ ;the tag ID for a custom path setting
Move.L D0,(A4)+ ;the paths returned by Ralph's routines
.NoPaths
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Move.L #TAG_DONE,(A4) ;end of the list
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Move.L _OutputBuffer(PC),A1 ;clean up the memory allocated to hold
Move.L _OutputBufLen(PC),D0 ;the data file so the user actually has
Cmp.L #0,A1 ;some memory to work with when they try
Beq.S .NoFileMemory ;to view the file
CALL FreeMem,EXEC
Clr.L _OutputBuffer ;clear data space so we don't try and free it upon exit
.NoFileMemory
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Move.L _Action(PC),A0 ;the program to run, as provided by the class entry
Lea CommandLine,A1 ;space to hold the final commandline
.CopyAction Move.B (A0)+,D0 ;copies a string
Cmp.B #'%',D0 ;was a % found in the string
Bne.S .IgnorePercent ;if not, then don't insert the filename
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Move.B (A0),D0 ;get the character after the %
Cmp.B #'s',D0 ;is it an s for string (ie, insert filename here)
Bne.S .IgnorePercent ;if not, then don't insert the filename
Tst.B _Quote ;are we ment to include quotes
Bne.S .NoFNQuote ;if not then jump to the copy routine
Move.B #'"',(A1)+ ;insert a quote
.NoFNQuote Move.L _FileName(PC),A2 ;the filename specified
Addq #1,A0 ;jump over the s in the action line
.CopyFName Move.B (A2)+,D0 ;gets a character
Move.B D0,(A1)+ ;puts it into the final commandline
Bne.S .CopyFName ;if it wasn't the end, then get another character
Moveq #1,D1 ;mark that we have already inserted the filename into the commandline
Subq #1,A1
Tst.B _Quote ;do we have to insert a quote
Bne.S .CopyAction ;if not, then carry on with the rest of the action entry
Move.B #'"',(A1)+ ;replace the space with a "
Bra.S .CopyAction ;carry on copying the rest of the action entry
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
.IgnorePercent Move.B D0,(A1)+ ;put the character into the command stream
Bne.S .CopyAction ;if it wasn't a zero, then go get another charcter
Cmp.B #1,D1 ;have we already inserted the filename
Beq.S .No2ndAction ;if so, then don't do it again
Move.B #' ',-1(A1) ;place a space after the command
Tst.B _Quote ;quote needed?
Bne.S .NoFNQuote2 ;if not, then don't put one in
Move.B #'"',(A1)+ ;throw a quote in before the start of the filename
.NoFNQuote2 Move.L _FileName(PC),A0 ;the name of the file to be viewed
Bsr StripQuotes ;copy the filename into the final commandline
Tst.B _Quote ;quote needed to clean things up?
Bne.S .No2ndAction ;if not, then don't put one in
Move.B #'"',-1(A1) ;close the pair of quotes surrounding the filename
.No2ndAction Clr.B (A1) ;mark the end of the commandline
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Move.L #CommandLine,D1 ;the commandline to be run
Move.L #_SystemTags,D2 ;any special tags to be attached to the newly created Process
CALL SystemTagList,DOS ;run the commandline
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Cmp.L #-1,D0 ;did System() return an error
Bne.S .NoWBPaths ;if not, then don't worry about cleaning up any possible paths
Tst.L _WBPaths ;if we were launched from workbench then the paths should have been set
Beq.S .NoWBPaths ;if not, then don't try and free them up
FreeWbPath _WBPaths(PC) ;free up the workbench paths using Ralph's routine
.NoWBPaths
Clr.L _WBPaths ;clear the paths entry if we are going to use it again later on